Shader "Perlin/Perlin2"
{
	Properties
	{
		_PermTex2D("PermTex2D", 2D) = "white" {}
		_GradTex2D("GradTex2D", 2D) = "white" {}
		_PermTexSize("PermTexSize", Float) = 256
		
		_UVScale("UVScale", Float) = 6.0
		_UVShift("UVShift", Float) = 0.0
		_NoiseScale("NoiseScale", Float) = 0.5
		_NoiseShift("NoiseShift", Float) = 0.5

		_Octaves("Octaves", Float) = 1
		_Lacunarity("Lacunarity", Float) = 1.92
		_Gain("Gain", Float) = 0.5
	}
	SubShader
	{
		Pass
		{
			CGPROGRAM
			
			#pragma vertex vert
			#pragma fragment frag
			#pragma target 4.0
			#pragma only_renderers d3d11
			
			#include "UnityCG.cginc"
			#include "Perlin.cginc"

			float _UVScale;
			float _UVShift;
			float _NoiseScale;
			float _NoiseShift;

			float _Octaves;
			float _Lacunarity;
			float _Gain;

			struct v2f
			{
				float4 pos : POSITION;
				float2 uv : TEXCOORD0;
			};

			v2f vert(appdata_base v)
			{
				v2f o;
				o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
				o.uv = v.texcoord.xy;
				return o;
			}

			float4 frag(v2f i) : COLOR
			{
				return perlinNoise2(i.uv*_UVScale+_UVShift, _Octaves, _Lacunarity, _Gain)*_NoiseScale+_NoiseShift;
			}

			ENDCG
		}
	}
	Fallback Off
}